import type {
  CreateCrudOptionsProps,
  CreateCrudOptionsRet,
} from '@fast-crud/fast-crud';

import type { SopPermIsvGroupModel } from '#/api/devOperation/sop/model/sopPermIsvGroupModel';

import { dict } from '@fast-crud/fast-crud';

import { SopPermGroupApi } from '#/api/devOperation/sop/sopPermGroup';

type ContextRef = object;

export function createCrudOptions(
  _props: CreateCrudOptionsProps<
    SopPermIsvGroupModel.SopPermIsvGroupResult,
    ContextRef
  >,
): CreateCrudOptionsRet<SopPermIsvGroupModel.SopPermIsvGroupResult> {
  return {
    crudOptions: {
      settings: { viewFormUseCellComponent: false },
      request: {
        addRequest: SopPermGroupApi.updateIsvGroupRequest,
      },
      form: {
        col: { span: 24 },
        // label 宽度
        labelCol: { span: null, style: { minWidth: '150px' } },
        // layout: 'vertical',
      },
      columns: {
        isvId: {
          form: { show: false },
        },
        groupIdList: {
          title: '分组',
          type: 'dict-checkbox',
          dict: dict({
            value: 'id',
            label: 'groupName',
            async getData() {
              return await SopPermGroupApi.query({});
            },
          }),
        },
      },
    },
  };
}
